/**
 * 
 */
package fhq.hcmute.modernshopping.adapter;

import java.io.Serializable;

import fhq.hcmute.qrcode.QRCode;

/**
 * @author: Hien Nguyen Le
 * @emai: hien.nguyenle.it@gmail.com
 * 
 */
public class Product implements Serializable {
	private static final long serialVersionUID = 6239542155577386161L;
	private int code;
	private String name;
	private double price;
	private String madeIn;
	private int quantity = 1;

	public Product(int code, String name, double price, String madeIn,
			int quantity) {
		super();
		this.code = code;
		this.name = name;
		this.price = price;
		this.madeIn = madeIn;
		this.quantity = quantity;
	}

	public static Product parse(QRCode QrCode) {
		String[] contents = QrCode.getContents().split(";");
		int code = Integer.parseInt(contents[0]);
		String name = contents[1];
		double price = Double.parseDouble(contents[2]);
		String madeIn = contents[3];
		return new Product(code, name, price, madeIn, 0);
	}

	public int getCode() {
		return code;
	}

	public String getName() {
		return name;
	}

	public double getPrice() {
		return price;
	}

	public String getMadeIn() {
		return madeIn;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
}
